using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities
{
    /// <summary>
    /// 网站主题实体
    /// 用于管理网站的视觉主题和样式配置
    /// </summary>
    [Table("themes")]
    public class Theme : ITenantEntity
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 主题名称
        /// </summary>
        [Required]
        [StringLength(255)]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 主题描述
        /// </summary>
        [Column(TypeName = "text")]
        public string? Description { get; set; }

        /// <summary>
        /// 主题预览图
        /// </summary>
        [StringLength(255)]
        public string? PreviewImage { get; set; }

        /// <summary>
        /// 主题配置
        /// JSON格式存储主题的颜色、字体等配置
        /// </summary>
        [Column(TypeName = "json")]
        public string? Config { get; set; }

        /// <summary>
        /// 主题CSS文件路径
        /// </summary>
        [StringLength(255)]
        public string? CssPath { get; set; }

        /// <summary>
        /// 主题JS文件路径
        /// </summary>
        [StringLength(255)]
        public string? JsPath { get; set; }

        /// <summary>
        /// 状态（启用/禁用）
        /// 0=禁用, 1=启用
        /// </summary>
        public byte Status { get; set; } = 1;

        /// <summary>
        /// 是否为默认主题
        /// </summary>
        public bool IsDefault { get; set; } = false;

        /// <summary>
        /// 创建人
        /// </summary>
        [Required]
        public long CreatedBy { get; set; }

        /// <summary>
        /// 修改人
        /// </summary>
        public long? UpdatedBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 创建人导航属性
        /// </summary>
        [ForeignKey(nameof(CreatedBy))]
        public User? Creator { get; set; }

        /// <summary>
        /// 修改人导航属性
        /// </summary>
        [ForeignKey(nameof(UpdatedBy))]
        public User? Updater { get; set; }

        /// <summary>
        /// 租户标识符
        /// </summary>
        public string TenantId { get; set; } = string.Empty;
    }
}
